X2t = X2;

c = [c(1:5) c(pdpos) c(dtpos) c(dtpos) c(dgpos) c(dgpos)];
pred_coint = c' + Psi * X2t(1:(T - 1), :)';

regx = [ones(T - 1, 1), X2t(1:(T - 1), :)];
regr = ols(X2t(2:T, dtpos), regx);
fitted_dt = regx * regr.beta;
regr = ols(X2t(2:T, dgpos), regx);
fitted_dg = regx * regr.beta;

ts_actual_dt = X2t(2:T, dtpos);
ts_var1y_dt = pred_coint(dtpos, :)';
ts_ols1y_dt = fitted_dt;

rmse1y_dt = [mean((ts_actual_dt - ts_var1y_dt) .^ 2), ...
                 mean((ts_actual_dt - ts_ols1y_dt) .^ 2)] * 1e4;

ts_actual_dg = X2t(2:T, dgpos);
ts_var1y_dg = pred_coint(dgpos, :)';
ts_ols1y_dg = fitted_dg;

rmse1y_dg = [mean((ts_actual_dg - ts_var1y_dg) .^ 2), ...
                 mean((ts_actual_dg - ts_ols1y_dg) .^ 2)] * 1e4;
